<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>counter</title>
<script src="lib/moment-with-locales.js"></script>
<link href="style/main.css" rel="stylesheet" type="text/css" />
    </head>
    <body style="text-align: center;padding: 1%;">
   
        <div id="currentTimeBox">
        <p style="font-size: 21px;">今天</p>
        <p id="currentTime" style="text-decoration: underline;font-weight: 600;font-size: 21px;">April 2nd 2021</p></div>
        <br>
        <div id="MainExamBox" style="background-color: greenyellow;width: auto;border-radius: 15px;padding: 10px;display: block;text-align: center;align-items: center;box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.12), 0px 2px 3px rgba(0, 0, 0, 0.24);">
            <p style="font-size: 28px;letter-spacing: 0.036em;font-weight: 400;">距离中考还剩</p>
            <br>
            <span id="MainExamTime" style="font-size: 67px;line-height: 1.5;letter-spacing: 0.097em;font-weight: 500;font-style: normal;color: #060e4f;border-radius: 19px;display: inline;box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.12), 0px 2px 3px rgba(0, 0, 0, 0.24);padding-left: 9px;padding-top: 5px;padding-right: 5px;padding-bottom: 5px;margin-top: 3px;margin-bottom: 3px;background-color: #f9ff2f;">72</span>    
    <span style="font-size: 27px;font-weight: 500;">天</span>
        </div>

        <br/>
        <div style="padding: 5px;background-color: aliceblue;border-radius: 19px;box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.12), 0px 2px 3px rgba(0, 0, 0, 0.24);">
            <table style="width: 100%;">
<tbody  id="smalllist"></tbody>
            </table>
        </div>

        <p style="bottom:0px;left:0;position:fixed;font-family: dhr_font;">Powered by zhengjiabao</p>
    
    
    <script>
        //setInterval(() => {
        //    run()
        //}, 1000*60*60);
        function base64ToUtf8 (base64) {
		// 对base64转编码
		var decode = atob(base64)
		// 编码转字符串
		var str = decodeURI(decode)
		// 字符串转为utf-8字节数组
		var utf8Arr = str.split(',')
		for (var i = 0; i < utf8Arr.length; i++) {
			utf8Arr[i] = utf8Arr[i] - 0
		}
		return utf8Arr.join("")
	}


        var run=()=>{
            var current
        moment.fn.daysFromNow = function(times) {
    return Math.ceil(-(+times - (+this))/(60000*60*24));
}
        var httpRequest = new XMLHttpRequest();
httpRequest.open('GET', 'http://quan.suning.com/getSysTime.do', true); 
httpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
httpRequest.send(null);
httpRequest.onreadystatechange = function () {
    if (httpRequest.readyState == 4 && httpRequest.status == 200) {
        current = moment(new Date(JSON.parse(httpRequest.responseText)["sysTime2"]));
        document.getElementById("currentTime").innerText=current.format('MMMM Do YYYY');
        if(moment("20210615", "YYYYMMDD").daysFromNow(current)<=10){
            document.getElementById("MainExamTime").style.color="red"
        }
        document.getElementById("MainExamTime").innerText=moment("20210615", "YYYYMMDD").daysFromNow(current);
        var httpRequest2 = new XMLHttpRequest();
httpRequest2.open('GET', 'http://localhost:40239/data/CountdownData/data.json', true); 
httpRequest2.setRequestHeader("Content-type","application/x-www-form-urlencoded");
httpRequest2.send(null);
httpRequest2.onreadystatechange = function () {
    if (httpRequest2.readyState == 4 && httpRequest2.status == 200) {

        console.log(JSON.parse(httpRequest.responseText))
        console.log(JSON.parse(httpRequest.responseText)["content"]);
        // var cont=base64ToUtf8(JSON.parse(httpRequest2.responseText)["content"]);
        // console.log(cont)
        //             let json = JSON.parse(cont);
		// 			var titlist=json
        var titlist=JSON.parse(httpRequest2.responseText)
                    for (let i = 0; i < titlist.length; i++) {
                const obj = titlist[i];
                if(moment(obj.date, "YYYYMMDD").daysFromNow(current)>0){
                    document.getElementById("smalllist").insertAdjacentHTML("beforeend",`
                <tr class="list_div" style="${obj.blod?"font-weight: 600;":""}">
                    <td class="list_name"><p>${obj.name}</p></td>
                    <td class="list_last"><p>${
                        moment(obj.date, "YYYYMMDD").daysFromNow(current)>2?"剩余"+moment(obj.date, "YYYYMMDD").daysFromNow(current)+"天":
                        moment(obj.date, "YYYYMMDD").daysFromNow(current)==1?"明天":"今天"}</p></td>
                    </tr>
                `)
                }
                

            }
				}
			}

        var titlist=[
            {
                "name":"第二次学情了解",
                "date":"20210405",
                "blod":false
            },{
                "name":"体育中考",
                "blod":true,
                "date":"20210414"
            },{
                "name":"一模",
                "blod":true,
                "date":"20210426"
            },{
                "name":"英语听力和人机对话中考",
                "blod":true,
                "date":"20210424"
            }
        ]
           
    }
};

        }
        run()
        
    </script>
      <script src="https://eqcn.ajz.miesnfu.com/wp-content/plugins/wp-3d-pony/live2dw/lib/L2Dwidget.min.js"></script>
      <script src="/js/hijiki.js"></script>
    </body>
</html>